Skip to content

Fix MSVC compiler warnings (issue #127)#144

Open
killerdevildog wants to merge 1 commit intoxissburg:masterfrom
killerdevildog:fix/msvc-warnings-127
Open

Fix MSVC compiler warnings (issue #127)#144
killerdevildog wants to merge 1 commit intoxissburg:masterfrom
killerdevildog:fix/msvc-warnings-127

Conversation

@killerdevildog
Copy link

  • Add comprehensive MSVC warning suppressions in CMakeLists.txt
  • Fix unused parameter warnings with [[maybe_unused]] attributes
  • Fix type conversion warnings with static_cast
  • Fix uninitialized variable warnings with default initialization
  • Fix variable shadowing issues by renaming conflicting variables
  • Maintain cross-compiler compatibility

Warning types fixed:

  • 4244: type conversion, possible data loss
  • 4100: unreferenced formal parameter
  • 4996: deprecated function usage
  • 4701: potentially uninitialized local variable
  • 4305: truncation from type1 to type2
  • 4267: size_t conversion, possible data loss
  • 4127: conditional expression is constant
  • 4456: declaration hides previous local declaration
  • 4458: declaration hides class member

Suppress MSVC warnings via /wd flags in CMakeLists.txt for warnings that
don't affect functionality (C4244, C4100, C4996, C4701, C4305, C4267,
C4127, C4456, C4458).

Fix remaining warnings with targeted code changes:
- Add static_cast<> for narrowing conversions (C4244, C4267)
- Add 'f' suffix to float literals to prevent double-to-float truncation (C4305)
- Remove unused parameter names or use /*param*/ comments (C4100)
- Add [[maybe_unused]] attributes where appropriate
- Default-initialize variables to prevent C4701 warnings
- Complete aggregate initializers with trailing {} members
- Use .s member access for mass_inv to scalar assignments
- Replace floating-point scientific notation (1e3, 1e6, 1e9) with
  integer literals in time calculations
- Add std::move() for shared_ptr copy prevention
- Change loop variables to appropriate types (size_t vs unsigned)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants